﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace storeSMS
{
    public partial class frmset : Form
    {
        public frmset()
        {
            InitializeComponent();
        }

        private void frmset_Load(object sender, EventArgs e)
        {
            string sql = "select top 1 com,bytl from configinfo";
            DataSet ds = DbHelperOleDb.Query(sql);
            if (ds.Tables[0].Rows.Count == 1)
            {
                cbbcom.Text = ds.Tables[0].Rows[0][0].ToString();
                cbbbyt.Text = ds.Tables[0].Rows[0][1].ToString();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string com;
            int bytl=0;
            com = cbbcom.Text;
            int.TryParse( cbbbyt.Text,out bytl);            
                string sql = string.Format("update configinfo set com='{0}',bytl='{1}'", com, bytl);
                if (DbHelperOleDb.ExecuteSql(sql) > 0)
                {
                    myinfo.com = com;
                    myinfo.bytl = bytl;
                    MessageBox.Show("更新成功！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("更新失败！");
                }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
